package main.Q2001_2100;

import java.util.HashMap;
import java.util.Map;

public class Q2001_2010 {
    public static void main(String[] args) {
        System.out.println("Question2001：");
        System.out.println("Question2002：");
        System.out.println("Question2003：");
        System.out.println("Question2004：");
        System.out.println("Question2005：");
        System.out.println("Question2006：差的绝对值为 K 的数对数目");
        System.out.println("Question2007：");
        System.out.println("Question2008：");
        System.out.println("Question2009：");
        System.out.println("Question2010：");
    }
}

class Question2006 {
    public int countKDifference(int[] nums, int k) {
        int result = 0;
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            map.put(num, map.getOrDefault(num, 0) + 1);
        }
        for (int num : map.keySet()) {
            if (map.containsKey(num + k)) {
                result += map.get(num) * map.get(num + k);
            }
        }
        return result;
    }
}